Usage.test
Call $tester->test('TestName')->compare($target,$actual)
to run a sub-test inside a test in your class
Chaining is not required
RunTests.All
On a class that extends \Taeluf\Tester
, call ExtendingClass::runAll()
to run the tests.
@deprecated this function no longer does anything.
Extra.RefreshBrowserTab
Call Taeluf\Tester::xdotoolRefreshFirefox($switchBackToCurrWindow = false)
to refresh your browser tab.
If you're writing you're using runAllToFile($file)
, this could come in handy.
@deprecated in favor of \Taeluf\Tester\Utility::xdotoolRefreshFirefox()
Example.ModifyOutput
public function htmlOutput($details){ ob_start();
$successStatement = $details->result ? '<span style="color:green;">success</span>' : '<span style="color:red;">fail</span>';
if ($details->error!=null)$successStatement = '<strong style="color:blue;">error</strong>';
if ($details->disabled===true)$successStatement = '<strong style="color:orange;">disabled</strong>';
$diff = $details->bench->diff;
if ($diff < 0.0001)$diff = '';
else $diff = 'in '.number_format($diff*1000,3).'ms';
echo "<details>\n <summary><b>".$details->method.":</b> ".$successStatement." {$diff} </summary>\n";
// echo " <div>Time to run: ".$details->bench->diff."</div>";
echo " <div style='padding-left:4ch;white-space:pre;'>\n";
$detailsOutput = htmlentities($details->output);
$detailsLines = explode("\n",$detailsOutput);
$detailsLines = array_map(function($value){return ' '.$value;},$detailsLines);
echo implode("\n",$detailsLines);
// var_dump($detailsLines);
echo "\n </div>";
if ($details->error!=null){
echo "\n <br>\n";
echo " <div style='color:red;padding-left:4ch;white-space:pre;'>\n";
$errorOutput = $details->error;
$errorLines = explode("\n",$errorOutput);
$errorLines = array_map(function($value){return ' '.$value;},$errorLines);
echo implode("\n",$errorLines);
echo "\n </div>";
}
echo "\n</details>\n";
return ob_get_clean();
}